package com.briup.cms.service.impl;

import com.briup.cms.bean.Category;
import com.briup.cms.dao.CategoryMapper;
import com.briup.cms.service.ICategoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CategoryServiceImpl implements ICategoryService {

    @Resource
    private CategoryMapper categoryMapper;

    @Override
    public List<Category> findAll() {
        return categoryMapper.selectAll();

    }

    @Override
    public void saveOrUpdate(Category category) { if(category.getId()!=null){
    categoryMapper.update(category);}
    else{
        categoryMapper.insert(category);
    }
    }

    @Override
    public void delete(long id) {
        categoryMapper.delete(id);
    }
}
